/*
 * motion_event.cpp
 *
 *  Created on: 30 May 2012
 *      Author: hframe
 */

#include "motion_event.h"

startnamespace(androidplus)
startnamespace(input)
startnamespace(event)

motion_event::motion_event(const AInputEvent *event){

		      downtime=AMotionEvent_getDownTime(event);
		      edgeflags=AMotionEvent_getEdgeFlags(event);
		      eventtime= AMotionEvent_getEventTime(event);
		      flags= AMotionEvent_getFlags(event);
		      pointercount= AMotionEvent_getPointerCount(event);
		      historysize= AMotionEvent_getHistorySize(event);
		      metastate= AMotionEvent_getMetaState(event);

		      orientation=new t_float[pointercount];
		      rawx=new t_float[pointercount];
		      rawy=new t_float[pointercount];
		      size=new t_float[pointercount];
		      toolmajor=new t_float[pointercount];
		      toolminor=new t_float[pointercount];
		      touchmajor=new t_float[pointercount];
		      touchminor=new t_float[pointercount];
		      pressure=new t_float[pointercount];
		      x=new t_float[pointercount];
		      y=new t_float[pointercount];
		      pointerid=new t_int32[pointercount];
		      for(int i=0;i<pointercount;++i){
		      orientation[i]= AMotionEvent_getOrientation(event,i);
		      pressure[i]=AMotionEvent_getPressure(event,i);
		      pointerid[i]= AMotionEvent_getPointerId(event,i);
		      rawx[i]= AMotionEvent_getRawX(event,i);
		      rawy[i]= AMotionEvent_getRawY(event,i);
		      size[i]=AMotionEvent_getSize(event,i);
		      toolmajor[i]= AMotionEvent_getToolMajor(event,i);
		      toolminor[i]=AMotionEvent_getToolMinor(event,i);
		      touchmajor[i]=AMotionEvent_getTouchMajor(event,i);
		      touchminor[i]=AMotionEvent_getTouchMinor(event,i);
		      x[i]=AMotionEvent_getX(event,i);
		      y[i]=AMotionEvent_getY(event,i);
		      }

		      xoffset=AMotionEvent_getXOffset(event);
		      xprecision= AMotionEvent_getXPrecision(event);
		      yoffset=AMotionEvent_getYOffset(event);
		      yprecision= AMotionEvent_getYPrecision(event);


}

motion_event::~motion_event() {
	              delete[] orientation;
			      delete[]rawx;
			      delete[] rawy;
			      delete[] size;
			      delete[]toolmajor;
			      delete[] toolminor;
			      delete[]touchmajor;
			      delete[] touchminor;
			      delete[]pressure;
			      delete[] x;
			      delete[] y;
			      delete[] pointerid;
}


                  t_int64 motion_event::get_downtime()const{	return downtime;}
			      t_int32 motion_event::motion_event::get_edgeflags()const{return edgeflags; }
			      t_int64 motion_event::get_eventtime()const{ return eventtime;}
			      t_int32 motion_event::get_flags()const{return flags;}
			      t_size motion_event::get_pointercount()const{return pointercount;}
			      t_size motion_event::get_historysize()const{return historysize;}
			      t_int32 motion_event::get_metastate()const{return metastate;}
			      const t_float *const motion_event::get_orientation()const{return orientation;}
			      const t_float *const motion_event::get_pressure()const{return pressure;}
			      const t_int32* motion_event::get_pointerid()const{return pointerid;}
			      const t_float *const motion_event::get_rawx()const{return rawx;}
			      const t_float *const motion_event::get_rawy()const{return rawy;}
			      const t_float *const motion_event::get_size()const{return size;}
			      const t_float *const motion_event::get_toolmajor()const{return toolmajor;}
			      const t_float *const motion_event::get_toolminor()const {return toolminor;}
			      const t_float *const motion_event::get_touchmajor()const{return touchmajor;}
			      const t_float *const motion_event::get_touchminor()const{return touchminor;}
			      const t_float *const motion_event::get_x()const{return x;}
			      const t_float *const motion_event::get_y()const{return y;}
			      t_float motion_event::get_xoffset()const{return xoffset;}
			      t_float motion_event::get_xprecision()const{return xprecision;}
			      t_float motion_event::get_yoffset()const{return yoffset;}
			      t_float motion_event::get_yprecision()const{return yprecision;}

endnamespace(event)
endnamespace(input)
endnamespace(androidplus)
